package com.googlecode.antilopebpm.instance.activity;

import java.util.Date;

import com.googlecode.antilopebpm.definition.ActivityDefinition;
import com.googlecode.antilopebpm.instance.Constant;
import com.googlecode.antilopebpm.instance.ProcessInstance;

public class ActivityInstance {

	private ActivityDefinition activityDefinition;
	private Long id;
	private String definitionId;
	private String name;
	protected ProcessInstance processInstance;
	protected Date createDate;
	private Date startDate;
	private Date completeDate;
	protected String currentState;

	private ActivityInstance() {

	}

	public ActivityInstance(ProcessInstance processInstance,
			ActivityDefinition activityDefinition) {
		this.processInstance = processInstance;
		this.activityDefinition = activityDefinition;

	}

	public ActivityDefinition getActivityDefinition() {
		return activityDefinition;
	}

	public Long getId() {
		return id;
	}

	public String getDefinitionId() {
		return definitionId;
	}

	public void setDefinitionId(String definitionId) {
		this.definitionId = definitionId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ProcessInstance getProcessInstance() {
		return processInstance;
	}

	public void complete() {
		this.completeDate = new Date();
		// TODO
		this.currentState = Constant.Activity_COMPLETED;
		this.processInstance.activityComplete(this);
	}

	public String getCurrentState() {
		return currentState;
	}

	public void setCurrentState(String currentState) {
		this.currentState = currentState;
	}
}